package com.wljy.developtool.controller;

import com.wljy.developtool.dto.Result;
import com.wljy.developtool.service.IMetricService;
import com.wljy.developtool.vo.QpsAddVO;
import com.wljy.developtool.vo.QpsQueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping(value = "/metric")
public class MetricController {

    @Autowired
    private IMetricService metricService;

    @PostMapping("/qpsAdd")
    public ResponseEntity qpsAdd(@RequestBody QpsAddVO qpsAddVO) {
        metricService.qpsAdd(qpsAddVO);
        return ResponseEntity.ok(null);
    }


    @GetMapping("/appQps")
    public ResponseEntity<Result> appQps(String app) {
        return ResponseEntity.ok(Result.success(metricService.appQps(app)));
    }

    @PostMapping("/qpsQuery")
    public ResponseEntity<Result> qpsQuery(@RequestBody QpsQueryVO qpsQueryVO) {
        return ResponseEntity.ok(Result.success(metricService.qpsQuery(qpsQueryVO)));
    }
}
